<?php
/**
 * @version			$Id: default.php 49 2010-08-17 05:28:47Z lowcosta@gmail.com $
 * @author			Richard Asp
 * @package			Joomla
 * @subpackage		gnudoor
 * @copyright		(C) 2010 gnudoor LLC
 * @license      GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

defined( '_JEXEC' ) or die( 'Restriced access' ); 
JHTML::_('stylesheet', 'view.css', 'components/com_gnudoor/assets/css/');
JHTML::_('stylesheet', 'form.css','components/com_gnudoor/assets/css/');
JHTML::_('stylesheet', 'tabs.css','components/com_gnudoor/assets/css/');
$params = &JComponentHelper::getParams( 'com_gnudoor' );
$topalias = $params->get( 'Consumer List page top' );
$bottomalias = $params->get( 'Consumer List page bottom' );
$model =& $this->getModel('Gnudoors');
$topID = $model->getArticleID($topalias);
$topid = $topID->id;
$bottomID = $model->getArticleID($bottomalias);
$bottomid = $bottomID->id;

$pencilgif = JHTML::image('components/com_gnudoor/assets/img/pencil02.gif','Edit', 'title="Change" width="16" height="16"');
$detailsgif = JHTML::image('components/com_gnudoor/assets/img/details16x30.gif','Details', 'title="Details" width="16" height="16"');
$nextstepgif = JHTML::image('components/com_gnudoor/assets/img/BlueArrowsRight16x17.gif','Next', 'title="Next Step" width="16" height="16"');
$link = 'index.php?option=com_gnudoor&controller=gnudoor&task=edit&cid=';
$linkshow = 'index.php?option=com_gnudoor&controller=gnudoor&task=viewrecord&cid=';
$linkadd = 'index.php?option=com_gnudoor&controller=gnudoor&controller=newtask';
if ($this->lists['active_tab'] == 'tab_three') {
//	$linknextstep = 'index.php?option=com_gnudoor&controller=pay&task=display&cid=';
	$linknextstep = 'index.php?option=com_gnudoor&controller=gnudoor&task=' . $this->lists['active_tab'] . '&cid=';
} else {
	$linknextstep = 'index.php?option=com_gnudoor&controller=gnudoor&task=' . $this->lists['active_tab'] . '&cid=';
}

?>

<script language="javascript" type="text/javascript">
function tableOrdering( order, dir, task )
{
        var form = document.adminForm;
 
        form.filter_order.value = order;
        form.filter_order_Dir.value = dir;
        document.adminForm.submit( task );
}
</script>
<?php echo file_get_contents($this->articlebase . $topid);?>
<ul id="globalnav">
  <li><a href="index.php?option=com_gnudoor&view=gnudoors&active_tab=tab_all" <?php if ($this->lists['active_tab'] == 'tab_all') {echo 'class="here"';} ?>>All</a></li>
  <li><a href="index.php?option=com_gnudoor&view=gnudoors&active_tab=tab_one" <?php if ($this->lists['active_tab'] == 'tab_one') {echo 'class="here"';} ?>><?php  echo $this->status[1]; ?></a></li>
  <li><a href="index.php?option=com_gnudoor&view=gnudoors&active_tab=tab_two" <?php if ($this->lists['active_tab'] == 'tab_two') {echo 'class="here"';} ?>><?php  echo $this->status[2]; ?></a></li>
  <li><a href="index.php?option=com_gnudoor&view=gnudoors&active_tab=tab_three" <?php if ($this->lists['active_tab'] == 'tab_three') {echo 'class="here"';} ?>><?php  echo $this->status[3]; ?></a></li>
  <li><a href="index.php?option=com_gnudoor&view=gnudoors&active_tab=tab_four" <?php if ($this->lists['active_tab'] == 'tab_four') {echo 'class="here"';} ?>><?php  echo $this->status[4]; ?></a></li>
  <li><a href="index.php?option=com_gnudoor&view=gnudoors&active_tab=tab_five" <?php if ($this->lists['active_tab'] == 'tab_five') {echo 'class="here"';} ?>><?php  echo $this->status[5]; ?></a></li>
  <li><a href="index.php?option=com_gnudoor&view=gnudoors&active_tab=tab_six" <?php if ($this->lists['active_tab'] == 'tab_six') {echo 'class="here"';} ?>><?php  echo $this->status[6]; ?></a></li>
</ul>


<div id="form_container" class="mylist">
<div>
<?php  if ($this->lists['active_tab'] == 'tab_one' ) { ?>
	<a href="<?php  echo $linkadd; ?>">Add <?php echo $this->titles[formHeader];?></a>
<?php  } else {
	 echo '&nbsp;'; // $this->titles[formHeader] . ' processing';	
  } ?>
</div>

<?php  echo $this->pagination->getPagesCounter(); ?>

<form id="adminForm" action="<?php echo JRoute::_( 'index.php' );?>" method="post" name="adminForm">

<table id="box-table-a">
<col width="80px" />
<col width="200px"  />
<col width="80px"  />
<col span="2" width="150px"  />
  <tr>
    <th><?php echo JHTML::_( 'grid.sort', $this->titles[formDate], 'dateAdded', $this->lists['order_Dir'], $this->lists['order']); ?></th>
    <th scope="col"><?php echo $this->titles[formName];?></th>
    <th><?php echo JHTML::_( 'grid.sort', $this->titles[formDueDate], 'dateDue', $this->lists['order_Dir'], $this->lists['order']); ?></th>
    <th scope="col"><?php echo $this->titles[formStatus];?></th>
    <th scope="col"><?php echo $this->titles[formProvider];?></th>
    <th scope="col">Actions</th>
  </tr>
<?php

if( count( $this->rows )) :
// if (isset($this->rows)){
	foreach($this->rows as $row) {
	    $thislink = $link . $row->id;
	    $thisview = $linkshow . $row->id;
	    $thisnextstep = $linknextstep . $row->id;
	 
 
?>

   <tr>
    <td><?php echo strftime('%b %d %Y', strtotime($row->dateAdded)); ?></td>
    <td><a href="<?php echo $thisview; ?>"><?php echo $row->name; ?></a></td>
    <td><?php 
    if ($row->dateDue == 0) {
    	echo 'not set';
    } else {
    	$format = '%m/%d/%y %H:%M %p';
    	$timest = strtotime($row->dateDue); 
    	echo strftime($format,$timest);
    }
    	?></td>
    <td><?php echo $this->status[$row->status]; ?></td>
    <td><?php 
    if ($row->bidid == 0) {
    	echo 'not assigned';
    } else {
    	$model = $this->getModel('Gnudoors');
    	echo $model->getProviderName($row->bidid)->name;
    } 
    
    ?></td>
    <td nowrap="nowrap">
    	<?php if ($this->lists['active_tab'] != 'tab_all') { if ($this->lists['active_tab'] == 'tab_one') { ?><a href="<?php echo $thislink; ?>"><?php  echo $pencilgif; ?></a>&nbsp;|  <?php } else { ?><?php  echo $pencilgif; ?>&nbsp;|   <?php } ?>&nbsp;<a href="<?php echo $thisview; ?>"><?php  echo $detailsgif; ?></a>&nbsp;|&nbsp;<?php if ($this->lists['active_tab'] == 'tab_five' | 'tab_six') { ?><?php  echo $nextstepgif; ?><?php } else { ?><a href="<?php echo $thisnextstep; ?>"><?php  echo $nextstepgif; ?></a><?php } }?> 
    </td>
  </tr>
<?php } endif; ?>

</table>
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />

</form>

</div>
<?php echo file_get_contents($this->articlebase . $bottomid);?>
<?php echo $this->pagination->getPagesLinks(); ?>
